package com.ehi.common.jersey.status;

import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;

@XmlRootElement
public class ErrorMessageWrapper implements Serializable {
    private static final long serialVersionUID = 9034616785786059295L;

    private ErrorMessage error;

    //@JsonIgnore
    private int statusCode;

    public ErrorMessageWrapper() {
    }

    public ErrorMessageWrapper(ErrorMessage error) {
        this.error = error;
    }

    public ErrorMessageWrapper(ErrorMessage error, int statusCode) {
        this.error = error;
        this.statusCode = statusCode;
    }

    public static ErrorMessageWrapper buildErrorMessage(
        ResponseTypeCode status, String message) {
        return new ErrorMessageWrapper(new ErrorMessage(status, message), status.getTypeCode());
    }

    public static ErrorMessageWrapper buildErrorMessage(
        ResponseTypeCode status, String message, String errorType) {
        return new ErrorMessageWrapper(new ErrorMessage(status, message, errorType), status.getTypeCode());
    }

    public ErrorMessage getError() {
        return error;
    }

    public void setError(ErrorMessage error) {
        this.error = error;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }
}
